Skip to content

fix(agc): clamp an exported pixel depth to the viewport depth range - #10348

Merged
oneandonlydean merged 9 commits into
boykopovar:mainfrom
oneandonlydean:perf-D2-v47
Oct 28, 2026
Merged

oneandonlydean merged 9 commits into
boykopovar:mainfrom
oneandonlydean:perf-D2-v47

Conversation

@oneandonlydean

@oneandonlydean oneandonlydean commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

What

A pixel shader that exports depth now has the exported value clamped to the viewport depth range before it reaches the depth attachment, as the DB does.

  • The pixel stage info carries PA_SC_VPORT_ZMIN_0 and ZMAX_0 when the shader exports depth (0 and 1 otherwise), and the recompiled shader NClamps the exported value to them before it stores gl_FragDepth. Only viewport 0 bounds the clamp.
  • With DB_RENDER_OVERRIDE.DISABLE_VIEWPORT_CLAMP set, the value is stored as exported. Non-finite or inverted bounds are rejected. DB_RENDER_OVERRIDE joins the draw key registers.
  • The bounds are part of the recompile cache key (only for depth-exporting shaders, so no other key changes), the draw key and its register check, and recompile requests.

The DB clamps an exported depth to ZMIN/ZMAX unless the override disables it. Vulkan only clamps with depthClamp, which also turns off clipping, so until now the exported value reached the depth attachment unclamped.

This writes recompile request version 49 and reads the depth bounds from version 49 on. Main is at version 48 (the barycentric built-ins flag from #9193); this branch keeps main's version-48 fields and adds the bounds after them. Version 46, 47 and 48 requests still decode, with default depth bounds.

Tested

Head d4a296d863 (main d13b3d7c55 merged in), compared with main d13b3d7c55, same machine, NVIDIA GeForce RTX 4090 (driver 610.57.04, Vulkan 1.4.341), Linux, Release build, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Khronos validation layer 1.4.363) and VK_LOADER_DEBUG=layer, so each log shows the loader inserting the layer. Tests selected: agc_driver_depth_export_clamp, agc_shader_memory, request_serializer, agc_driver_graphics, agc_masked_select and every test with depth in its name.

main d13b3d7c55 head d4a296d863
tests passed / failed / skipped 42 / 0 / 0 43 / 0 / 0
Insert instance layer "VK_LAYER_KHRONOS_validation" (loader lines) 44 45
was not found but was requested 0 0
VUID- lines 0 0

There are a couple more inserted-layer lines than tests because some tests create more than one Vulkan instance.

The extra passing test on the head is agc_driver_depth_export_clamp, which does not exist on main. It runs on the device.

  • A shader that exports 1.5 with a viewport depth range of [0.25, 0.75] leaves 0.75 in the depth buffer, and an export of -0.5 leaves 0.25. With the override set, the exported value is stored as it is.
  • With the emitter changed to always store the exported value unclamped, agc_driver_depth_export_clamp and agc_shader_memory fail, so the tests cover the clamp.
  • The pixel stage decode reads the bounds, passes the disable flag through, rejects bad bounds, and leaves a draw without depth export at 0 and 1. The bounds survive serialization and key the cache.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux
  • AI-assisted: yes

The DB clamps a pixel shader's exported depth to PA_SC_VPORT_ZMIN_0 and
ZMAX_0 unless DB_RENDER_OVERRIDE.DISABLE_VIEWPORT_CLAMP is set. Vulkan only
clamps with depthClamp, which also drops clipping, so the exported value
reached the depth attachment unclamped.

The pixel stage info now carries the two bounds when the shader exports
depth (0 and 1 otherwise), and the exported value is NClamped to them
before it is stored to gl_FragDepth. With
DISABLE_VIEWPORT_CLAMP the value is stored as exported; non-finite or
inverted bounds are rejected. DB_RENDER_OVERRIDE joins the draw key
registers. The bounds
are part of the recompile cache key (only for depth-exporting shaders, so
other keys do not change), the draw key and its register check, and
recompile requests (serialization version 47).

Tests: the pixel stage decode reads the bounds, passes the disable flag through
and rejects bad bounds, and leaves a draw without depth export at 0 and 1; a
recompiled depth export stores the NClamped value, and its bounds survive
serialization and key the cache.

Request version 47: main is at 44 (boykopovar#8612) and open PRs also claim 44 to 46 (boykopovar#8564, boykopovar#7888, boykopovar#9193 and the boykopovar#9020, boykopovar#9335, boykopovar#9748 stack). Whichever of these lands second renumbers.
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed shader core/shader agc libSceAgc* labels Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10359 core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp L856, L906
PR 10547 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L6244, L6365, L6755-6756
core/shader/recompiler/tests/RequestSerializerTests.cpp L301, L345, L375, L509, L536-537, L554, L581, L610-611, L621, L751
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L6244, L6365, L6755-6756
core/shader/recompiler/tests/RequestSerializerTests.cpp L301, L345, L375, L509, L536-537, L554, L581, L610, L621, L751

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 2434 docs/dev/debt/libSceAgcDriver.md
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5609 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/shader/recompiler/Recompiler.hpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/libSceAgcDriver.md
PR 6185 docs/dev/debt/libSceAgcDriver.md
PR 6186 docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/shader/recompiler/Recompiler.hpp
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Optimization/include/Optimization/ShaderStageInputInfo.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6970 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.hpp
PR 6977 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7410 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderInputState.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 8004 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 8223 docs/dev/debt/libSceAgcDriver.md
PR 8319 docs/dev/debt/libSceAgcDriver.md
PR 8395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8542 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 8874 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9020 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Optimization/include/Optimization/ShaderStageInputInfo.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9335 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Optimization/include/Optimization/ShaderStageInputInfo.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9431 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9432 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9489 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9533 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9672 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9673 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9674 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9675 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9676 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9700 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9717 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9742 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9748 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Optimization/include/Optimization/ShaderStageInputInfo.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9790 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9842 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9852 core/shader/recompiler/Recompiler.hpp
PR 9889 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9891 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9892 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9893 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9895 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
docs/dev/debt/libSceAgcDriver.md
PR 9897 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.hpp
PR 9898 docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 9969 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10000 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.hpp
PR 10049 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/Recompiler.hpp
docs/dev/debt/libSceAgcDriver.md
PR 10064 docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10233 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderInputState.cpp
PR 10333 docs/dev/debt/libSceAgcDriver.md
PR 10435 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10489 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.hpp
PR 10581 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10757 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Recompiler.hpp
PR 10846 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 11351 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/CacheKey.hpp
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp
core/shader/recompiler/Optimization/include/Optimization/ShaderStageInputInfo.hpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
core/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cpp
core/shader/recompiler/tests/RequestSerializerTests.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11557 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11998 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 12238 docs/dev/debt/libSceAgcDriver.md

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reported RTX 4090 run covers the changed head, but this PR changes both the AGC driver and shader recompiler. CONTRIBUTING requires the same focused tests on main and this change, on the same machine and GPU, with VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, and ANYPS5_REQUIRE_VULKAN=1, plus confirmation that the requested layer loaded and a comparison showing no new VUID- errors. Please add those baseline/change results (including the depth-export test and relevant serializer coverage) before merge. I could not dispatch the repository's manual build workflow from this account; GitHub returned HTTP 403 because workflow dispatch requires repository admin rights. My local configure also cannot reach the test build: this checkout has no SDL2 submodule sources and the host lacks XRandR development support, so I did not run the product tests.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@adriadam10 adriadam10 self-assigned this Oct 24, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change reads right: the exported value is NClamped to PA_SC_VPORT_ZMIN_0/ZMAX_0 unless DB_RENDER_OVERRIDE bit 16 is set, the bounds key the draw, the recompile cache (depth-exporting shaders only) and the serializer, and the new tests fail without the clamp. Two things block it:

  • It conflicts with main, which now writes request version 46 (#8564: targetMerge fields at the end of readPixelInfo/writePixelInfo). The bounds must be written and read after the targetMerge block, gated on version >= 47, and the version fixtures in RequestSerializerTests.cpp and ShaderMemory.cpp (base64 prefixes, the byte-stripping legacy fixtures, "future version") need redoing on top of 46. Conflicts are in RequestSerializer.cpp, ShaderMemory.cpp and RequestSerializerTests.cpp.
  • @MarcZX10's change request is still open: CONTRIBUTING needs the same focused tests (agc_driver_depth_export_clamp, agc_shader_memory, request_serializer, the depth tests) on main and on this branch, same machine and GPU, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, confirmation that the layer loaded, and a comparison showing no new VUID- errors. Please add those logs to Tested after rebasing.

A pixel shader that exports depth now reads DB_RENDER_OVERRIDE and the viewport
depth bounds (PA_SC_VPORT_ZMIN_0 and ZMAX_0) while its stage info is decoded. The
stencil replay test builds its context registers by hand and left them out, so
the decode threw "missing register at DWORD 0x3" for its depth-exporting shader.
The test now sets the override off and the bounds to 0 and 1, which is what the
decode produced before the clamp.
@babyhuey

Copy link
Copy Markdown
Contributor

Windows run of this head c8f6a33164d, merged onto main 710cf9c0352 (clean merge, local only), with the selection CI's skipped Windows product job uses: Windows 11, Ryzen 7 5800X, RTX 3080, WinLibs GCC 15.2, Release, BUILD_TESTING=ON. The tree was configured fresh after the merge, then select_tests.py select / ninja -f select.ninja selected / --target libs / select_tests.py ctest --parallel 4 --timeout 120, with check_skips.py --job windows.

AI-assisted: yes (Claude Code)

@wachi35676

Copy link
Copy Markdown
Contributor

First Windows run of the device test, and the first on AMD. Windows 11 10.0.26300, WinLibs GCC 15.2.0, Release; this head c8f6a33164 merged onto main a3987a1 (clean); ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; NVIDIA RTX 5070 Ti (621.01) and AMD Radeon RDNA2 iGPU (AMD proprietary 2026.04.17, ANYPS5_GPU=AMD).

  • 66 related entries (depth, stencil, pixel, agc_shader_memory, request_serializer, agc_driver_graphics): 64/66 on both GPUs. agc_driver_depth_export_clamp passes on both; agc_driver_stencil_ref_export skips on NVIDIA. The two failures, agc_host_import_cut_lifetime (agc_host_import_cut_lifetime fails on Windows since the merge of #9159 #10746) and agc_driver_depth_plane_partial_store (AGC: imported depth-plane partial-store test fails refresh-proof assertion on Windows (NVIDIA and AMD) #10664), also fail without the change here.
  • Control, with main's SpirvModuleEmitter.cpp and everything else from this PR: on both GPUs agc_driver_depth_export_clamp fails (an exported depth of 1.5 was not clamped to ZMAX 0.75), and so does agc_shader_memory (the exported depth was not NClamped to [ZMIN, ZMAX]). Nothing else changes. So neither driver applies the viewport range to FragDepth by itself.
  • The serializer paragraph in the description is out of date: main is at version 46 now, and this branch's 47 already sits after the version-46 target-merge fields.
  • Only PA_SC_VPORT_ZMIN_0/ZMAX_0 are read, so a program that selects another viewport is clamped to viewport 0's range. Is that worth a debt line?

AI-assisted: yes (Claude Code); results above were run on this machine.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rebase onto version 46 reads right: the bounds are written after the targetMerge block, read with version >= 47, and the fixtures were redone. @wachi35676's control run (main's emitter with the rest of this PR) fails agc_driver_depth_export_clamp and agc_shader_memory on NVIDIA and AMD, so the tests cover the clamp. Two things are left:

  • @MarcZX10's request is still open and nobody has supplied it: CONTRIBUTING needs the same focused tests (agc_driver_depth_export_clamp, agc_shader_memory, request_serializer, the depth tests) on main and on this head, same machine and GPU, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, confirmation that the layer loaded (no was not found but was requested by env var VK_INSTANCE_LAYERS in either log), and a comparison showing no new VUID- errors. The Windows runs above don't use the layer. Please add those logs to Tested.
  • The description is out of date: it says main is at version 45 and that this writes 46/47 with other PRs holding 46. Main is at 46 now and this branch writes 47 after its fields. Please correct What and update Tested with the run on the current head.

Also, as wachi35676 noted, only PA_SC_VPORT_ZMIN_0/ZMAX_0 are read, so a draw that selects another viewport is clamped to viewport 0's range; please add a line for that in docs/dev/debt/ for the AGC driver.

@oneandonlydean oneandonlydean self-assigned this Oct 27, 2026
The clamp reads PA_SC_VPORT_ZMIN_0 and PA_SC_VPORT_ZMAX_0 only, so a draw that
selects another viewport is clamped to viewport 0's depth range.
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed docs labels Oct 27, 2026
…on 48

Main took request serialization version 47 for the two-sample dithered
alpha-to-coverage value. The depth export clamp bounds are now written at
version 48 and read only for versions from 48, so a version 47 request as main
writes it still decodes, with default bounds. Tests: version 48 is the
emitted prefix, 49 the first unsupported one, and a version 47 two-sample
dithered request (with and without depth export) decodes as written.
require takes a C string; the version 46 and 47 depth export messages were
built with std::string and did not compile.
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 27, 2026
…on 49

Main took request serialization version 48 for the fragment barycentric
built-ins flag (boykopovar#9193). The depth export clamp bounds are now written at
version 49 and read only for versions from 49, so a version 48 request as main
writes it still decodes, with default bounds. Tests: version 49 is the
emitted prefix, 50 the first unsupported one, a depth exporting request
without its bounds decodes at 48, 47 and 46 (the last two without main's
barycentric byte), and a version 48 two-sample dithered request decodes as
written.
@oneandonlydean

Copy link
Copy Markdown
Collaborator Author

@adriadam10 thanks, all three are done on the current head d4a296d863:

  • Merged current main (d13b3d7c55). main has taken version 48 for the barycentric built-ins flag (feat(recompiler): read I/J from barycentric built-ins on MoltenVK #9193), so the depth bounds now move to version 49, written after main's version-48 fields; versions 46 to 48 still decode with default bounds.
  • Tested now has the focused tests on main d13b3d7c55 and on this head, same RTX 4090, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. VK_LOADER_DEBUG=layer shows the loader inserting the layer in both logs, there is no was not found but was requested line, and neither side has a VUID- line (42 passed on main, 43 on the head; the extra one is agc_driver_depth_export_clamp).
  • The viewport 0 limit is in docs/dev/debt/libSceAgcDriver.md.

The description is updated to match.

# Conflicts:
#	docs/dev/debt/libSceAgcDriver.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 28, 2026
@oneandonlydean
oneandonlydean dismissed stale reviews from adriadam10 and adriadam10 October 28, 2026 05:23

All three points are addressed on the current head (description at v49, validation-layer Tested table, viewport 0 debt line); see the reply above. Dismissing so the merge check can run; happy to revisit if anything is still open.

@oneandonlydean
oneandonlydean merged commit 00e85fe into boykopovar:main Oct 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants